﻿using System;
using System.Collections.Generic;

namespace CBCore
{
    public static class CBHelper
    {
        public static string HtmlFilter(string html)
        {
            string noStyle = html.Replace("&quot;", "\"").Replace("&lt;", "<").Replace("&gt;", ">").Replace("&quot;", "\"").Replace("&nbsp;", "");
            noStyle = System.Text.RegularExpressions.Regex.Replace(noStyle, "<[\\w\\W]*?>", "",
            System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            noStyle = System.Text.RegularExpressions.Regex.Replace(noStyle, @"\s", "",
            System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            return noStyle;
        }

        public static void VideoCutter(string sourceVideoFullPath, string outVideoFullPath, int startSeconds, int cutSeconds2)
        {
            VideoHelper.Cut(sourceVideoFullPath, outVideoFullPath, startSeconds, cutSeconds2).GetAwaiter().GetResult();
        }
        public static void VideoMerge(string sourceVideoFullPath,string endVideoFullPath,string outVideoFullPath)
        {
            var videos = new List<string>();
            videos.Add(sourceVideoFullPath);
            videos.Add(endVideoFullPath);
            VideoHelper.Merge(outVideoFullPath, videos.ToArray()).GetAwaiter().GetResult();
        }
        public static string VideoInfo(string videoPath)
        {
            try
            {
                var c = VideoHelper.VideoInfoAsync(videoPath);
                if (c.Result == null)
                {
                    return "NULLSSSSSSS";
                }
                return "SUCCESS"+":"+c.Result.Width.ToString()+","+c.Result.Height.ToString()+","+c.Result.Seconds.ToString();
            }
            catch(Exception exp)
            {
                return exp.Message;
            }
        }
    }
}
